package cn.ytnet.shangyun.service.basic.entity;

import org.springframework.stereotype.Component;

import javax.persistence.*;

/**
 * Created by cyongk on 2015/12/8.
 * ClassName:CountyEntity
 * ChineseName:行政区域县（区）类
 */
@Component("countyEntity")
@Entity
@Table(name = "T_County", schema = "crebas", catalog = "")
public class CountyEntity {
    private String pkTCountyId;
    private String countyName;
    private String countyPhoneticcode;

    private CityEntity cityEntity;//市（城市、地区）

    @ManyToOne(cascade = CascadeType.ALL,fetch = FetchType.EAGER)
    @JoinColumn(name = "pk_t_city_id")
    public CityEntity getCityEntity() {
        return cityEntity;
    }

    public void setCityEntity(CityEntity cityEntity) {
        this.cityEntity = cityEntity;
    }

    @Id
    @Column(name = "pk_t_county_id", nullable = false, length = 5)
    public String getPkTCountyId() {
        return pkTCountyId;
    }

    public void setPkTCountyId(String pkTCountyId) {
        this.pkTCountyId = pkTCountyId;
    }

    @Basic
    @Column(name = "county_name", nullable = false, length = 30)
    public String getCountyName() {
        return countyName;
    }

    public void setCountyName(String countyName) {
        this.countyName = countyName;
    }

    @Basic
    @Column(name = "county_phoneticcode", nullable = false, length = 100)
    public String getCountyPhoneticcode() {
        return countyPhoneticcode;
    }

    public void setCountyPhoneticcode(String countyPhoneticcode) {
        this.countyPhoneticcode = countyPhoneticcode;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        CountyEntity that = (CountyEntity) o;

        if (pkTCountyId != null ? !pkTCountyId.equals(that.pkTCountyId) : that.pkTCountyId != null) return false;
        if (countyName != null ? !countyName.equals(that.countyName) : that.countyName != null) return false;
        return countyPhoneticcode != null ? countyPhoneticcode.equals(that.countyPhoneticcode) : that.countyPhoneticcode == null;

    }

    @Override
    public int hashCode() {
        int result = pkTCountyId != null ? pkTCountyId.hashCode() : 0;
        result = 31 * result + (countyName != null ? countyName.hashCode() : 0);
        result = 31 * result + (countyPhoneticcode != null ? countyPhoneticcode.hashCode() : 0);
        return result;
    }
}
